home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / edit / me_cd25.zip / MUTT2.ZIP / BSTATS.MUT < prev    next >
Text File  |  1992-11-09  |  3KB  |  110 lines

  1.     ;; bstats.mut : buffer stats
  2.     ;; C Durland    Public Domain
  3.  
  4. (include me2.h)
  5. (include tobase.mut)
  6.  
  7. (defun
  8.   show-buffer-stats
  9.   {
  10.     (int buffer-size dot lines buffer-row wasted char-at-dot)    ;; BufferInfo
  11.     (int ratio)
  12.  
  13.     (buffer-stats -1 (loc buffer-size))
  14.     (ratio 0)(if (!= 0 buffer-size)(ratio (/ (* 100 dot) buffer-size)))
  15.     (msg "Row: " buffer-row "/" lines  " Column: " (current-column)
  16.     " CH: 0x" (tobase char-at-dot 16)
  17.     " (" ratio "% of " buffer-size ")")
  18.   }
  19. )
  20.  
  21. (defun
  22.   popup-buffer(int buffer-id) HIDDEN
  23.   {
  24.     (int j cw)
  25.  
  26.     (j 0)(while (< j (windows))
  27.     {
  28.       (if (== buffer-id (attached-buffer j))    ;; window j is showing buffer
  29.     (done))
  30.       (+= j 1)
  31.     })
  32.     (if (== (windows) 1)(split-window))
  33.     (next-window)
  34.     (current-buffer buffer-id TRUE)
  35.     (previous-window)
  36.   })
  37.  
  38.     ;; Put a list of buffer into a buffer.  Show various infos about those
  39.     ;;   buffers.
  40.     ;; Format:
  41.     ;;   Flags        buffer-size    buffer-name    file-name
  42.     ;;   Modified
  43.     ;;   Undo turned on
  44.     ;;   hidden - hard
  45.     ;;   hidden - soft
  46.     ;;   MUhH, dashes used if flag not set.
  47. (const end-size-col 12 file-col 29)
  48. (defun
  49.   list-buffers
  50.   {
  51.     (int buffer-size dot lines row wasted char-at-dot)    ;; struct BufferInfo
  52.     (int total-bytes total-lines)
  53.     (int j num-buffers cw bp bp1 wp old-curbp)
  54.  
  55.     (num-buffers (total-bytes (total-lines 0)))
  56.     (old-curbp (current-buffer))
  57.  
  58.     (if (== -2 (bp (attached-buffer "*buffer-list*")))
  59.     (bp (create-buffer "*buffer-list*" BFHooHum)))
  60.     (current-buffer bp)
  61.     (clear-buffer)
  62.     (insert-text "Flags  Size Buffer           File")(newline)
  63.     (insert-text "-----  ---- ------           ----")(newline)
  64.     (for (j 0) (< j (buffers)) (+= j 1)
  65.     {
  66.       (bp1 (nth-buffer j))
  67.       (if (!= bp bp1)
  68.       {
  69.     (buffer-stats bp1 (loc buffer-size))
  70.  
  71. ;    (insert-text (if (buffer-modified bp1)("*")(" ")))
  72.  
  73.     (if (!= 0 (bit-and BFNoCare (buffer-flags bp1)))
  74.       (insert-text ".")
  75.       (show-flag bp1 BFModified "M"))
  76.  
  77.     (show-flag bp1 BFUndo     "u")
  78.     (show-flag bp1 BFHidden   "H")
  79.     (show-flag bp1 BFHidden2  "h")
  80.  
  81.     (to-col (- end-size-col (length-of (concat buffer-size))))
  82.     (insert-text buffer-size)
  83.  
  84.     (insert-text " " (buffer-name bp1))
  85.     (to-col file-col)(insert-text (file-name bp1))
  86.  
  87.     (newline)
  88.     (+= num-buffers 1)(+= total-bytes buffer-size)(+= total-lines lines)
  89.       })
  90.     })
  91.  
  92.     (newline)
  93.     (to-col (- 9 (length-of (concat total-bytes))))
  94.     (insert-text total-bytes " bytes (" total-lines " lines) in "
  95.     num-buffers " buffers.  ")
  96.  
  97.     (beginning-of-buffer)
  98.     (buffer-modified -1 FALSE)
  99.  
  100.     (current-buffer old-curbp)
  101.  
  102.     (popup-buffer bp)
  103.   }
  104.   show-flag (int buffer-id flag)(string flag-on) HIDDEN
  105.   {
  106.     (insert-text
  107.       (if (!= 0 (bit-and flag (buffer-flags buffer-id))) flag-on "-"))
  108.   }
  109. )
  110.